/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

import java.io.Serializable;

import javax.persistence.*;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.springframework.security.GrantedAuthority;

/**
 *
 * @author click
 */
@Entity
@Table(name="options")
@NamedQueries ({
    @NamedQuery(
        name = "findOptionByName",
        query = "select o from Option o where o.name = :name "
        )
})
public class Option extends BaseObject implements Serializable, GrantedAuthority {
    private static final long serialVersionUID = 3832626162173359411L;
    private Long idOption;
    private String name;
    private String page;
    private String parent_name;
    private String title;
    private String description;
    private String location;
    private String target;
    private String onclick;
    private String onmouseover;
    private String onmouseout;
    private String image;
    private String altImage;
    private String tooltip;
    private String width;
    private String height;
    private String forward;
    private String action;

    public Option() { }

    @Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
    @Column(name="id_option")
    public Long getIdOption() {
        return idOption;
    }

    @Column(nullable=false,length=50,unique=true)
    public String getName() {
        return name;
    }
    @Column(nullable=true,length=50)
    public String getAction() {
        return action;
    }
    @Column(nullable=true,length=50)
    public String getAltImage() {
        return altImage;
    }
    @Column(nullable=true,length=255)
    public String getDescription() {
        return description;
    }
    @Column(nullable=true,length=50)
    public String getForward() {
        return forward;
    }
    @Column(nullable=true,length=5)
    public String getHeight() {
        return height;
    }
    @Column(nullable=true,length=50)
    public String getImage() {
        return image;
    }
    @Column(nullable=true,length=255)
    public String getLocation() {
        return location;
    }
    @Column(nullable=true,length=100)
    public String getOnclick() {
        return onclick;
    }
    @Column(nullable=true,length=100)
    public String getOnmouseout() {
        return onmouseout;
    }
    @Column(nullable=true,length=100)
    public String getOnmouseover() {
        return onmouseover;
    }
    @Column(nullable=true,length=30)
    public String getParent_name() {
        return parent_name;
    }
    @Column(nullable=true,length=10)
    public String getTarget() {
        return target;
    }
    @Column(nullable=true,length=30)
    public String getTitle() {
        return title;
    }
    @Column(nullable=true,length=100)
    public String getTooltip() {
        return tooltip;
    }
    @Column(nullable=true,length=5)
    public String getWidth() {
        return width;
    }

    /**
     * @see org.springframework.security.GrantedAuthority#getAuthority()
     * @return the name property (getAuthority required by Acegi's GrantedAuthority interface)
     */
    @Transient
    public String getAuthority() {
        return getName();
    }

    @Column(nullable=false,length=50,unique=true)
    public String getPage() {
        return page;
    }

    public void setIdOption(Long idOption) {
        this.idOption = idOption;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public void setAltImage(String altImage) {
        this.altImage = altImage;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setForward(String forward) {
        this.forward = forward;
    }

    public void setHeight(String height) {
        this.height = height;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public void setOnclick(String onclick) {
        this.onclick = onclick;
    }

    public void setOnmouseout(String onmouseout) {
        this.onmouseout = onmouseout;
    }

    public void setOnmouseover(String onmouseover) {
        this.onmouseover = onmouseover;
    }

    public void setParent_name(String parent_name) {
        this.parent_name = parent_name;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void setTooltip(String tooltip) {
        this.tooltip = tooltip;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Option other = (Option) obj;
        if (this.idOption != other.idOption && (this.idOption == null || !this.idOption.equals(other.idOption))) {
            return false;
        }
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        if ((this.page == null) ? (other.page != null) : !this.page.equals(other.page)) {
            return false;
        }
        if ((this.parent_name == null) ? (other.parent_name != null) : !this.parent_name.equals(other.parent_name)) {
            return false;
        }
        if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) {
            return false;
        }
        if ((this.description == null) ? (other.description != null) : !this.description.equals(other.description)) {
            return false;
        }
        if ((this.location == null) ? (other.location != null) : !this.location.equals(other.location)) {
            return false;
        }
        if ((this.target == null) ? (other.target != null) : !this.target.equals(other.target)) {
            return false;
        }
        if ((this.onclick == null) ? (other.onclick != null) : !this.onclick.equals(other.onclick)) {
            return false;
        }
        if ((this.onmouseover == null) ? (other.onmouseover != null) : !this.onmouseover.equals(other.onmouseover)) {
            return false;
        }
        if ((this.onmouseout == null) ? (other.onmouseout != null) : !this.onmouseout.equals(other.onmouseout)) {
            return false;
        }
        if ((this.image == null) ? (other.image != null) : !this.image.equals(other.image)) {
            return false;
        }
        if ((this.altImage == null) ? (other.altImage != null) : !this.altImage.equals(other.altImage)) {
            return false;
        }
        if ((this.tooltip == null) ? (other.tooltip != null) : !this.tooltip.equals(other.tooltip)) {
            return false;
        }
        if ((this.width == null) ? (other.width != null) : !this.width.equals(other.width)) {
            return false;
        }
        if ((this.height == null) ? (other.height != null) : !this.height.equals(other.height)) {
            return false;
        }
        if ((this.forward == null) ? (other.forward != null) : !this.forward.equals(other.forward)) {
            return false;
        }
        if ((this.action == null) ? (other.action != null) : !this.action.equals(other.action)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 83 * hash + (this.idOption != null ? this.idOption.hashCode() : 0);
        hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 83 * hash + (this.page != null ? this.page.hashCode() : 0);
        hash = 83 * hash + (this.parent_name != null ? this.parent_name.hashCode() : 0);
        hash = 83 * hash + (this.title != null ? this.title.hashCode() : 0);
        hash = 83 * hash + (this.description != null ? this.description.hashCode() : 0);
        hash = 83 * hash + (this.location != null ? this.location.hashCode() : 0);
        hash = 83 * hash + (this.target != null ? this.target.hashCode() : 0);
        hash = 83 * hash + (this.onclick != null ? this.onclick.hashCode() : 0);
        hash = 83 * hash + (this.onmouseover != null ? this.onmouseover.hashCode() : 0);
        hash = 83 * hash + (this.onmouseout != null ? this.onmouseout.hashCode() : 0);
        hash = 83 * hash + (this.image != null ? this.image.hashCode() : 0);
        hash = 83 * hash + (this.altImage != null ? this.altImage.hashCode() : 0);
        hash = 83 * hash + (this.tooltip != null ? this.tooltip.hashCode() : 0);
        hash = 83 * hash + (this.width != null ? this.width.hashCode() : 0);
        hash = 83 * hash + (this.height != null ? this.height.hashCode() : 0);
        hash = 83 * hash + (this.forward != null ? this.forward.hashCode() : 0);
        hash = 83 * hash + (this.action != null ? this.action.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
                .append(this.idOption).append(this.name).append(this.page)
                .append(this.parent_name).append(this.title).append(this.description)
                .append(this.location).append(this.target).append(this.onclick)
                .append(this.onmouseover).append(this.onmouseout).append(this.image)
                .append(this.altImage).append(this.tooltip).append(this.width)
                .append(this.height).append(this.forward).append(this.action).toString();
    }

    public int compareTo(Object o) {
         return (equals(o) ? 0 : -1);
    }
}
